package com.zjht.gmcc.bean.action;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.zjht.gmcc.bean.util.MyJDBC;

public class BizAmountUtil implements java.io.Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 根据rangeid获得rangename
	 * @author 孙汉斌 2011-12-01
	 * @param rangeid
	 * @return rangename
	 */

	public static String getRangeName(String rangeid) {
		String rangename = "";
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String sql = "SELECT rangename FROM Ranges WHERE rangeid=?";
			PreparedStatement ps = myJDBC.prepareStatement(sql);
			ps.setString(1, rangeid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				rangename = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return rangename;
	}

	/**
	 * 根据providerid(供应商ID)获取providername(供应商名称)
	 * @author 孙汉斌 2011-12-01
	 * @param providerid
	 * @return providername
	 */

	public static String getProviderName(String providerid) {
		String providername = "";
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String sql = "SELECT providername FROM Provider WHERE providerid=?";
			PreparedStatement ps = myJDBC.prepareStatement(sql);
			ps.setString(1, providerid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				providername = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return providername;

	}

	/**
	 * 根据providerid(供应商ID)获得providercode(供应商编码)
	 * @author 孙汉斌 2011-12-01
	 * @param providerid
	 * @return providercode
	 */

	public static String getProviderCode(String providerid) {
		String providercode = "";
		MyJDBC myJDBC = null;
		try {
			myJDBC = new MyJDBC();
			String sql = "SELECT UPPER(providercode) FROM Provider WHERE providerid=?";
			PreparedStatement ps = myJDBC.prepareStatement(sql);
			ps.setString(1, providerid);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				providercode = rs.getString(1);
			}
			rs.close();
			rs = null;
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			MyJDBC.close(myJDBC);
		}
		return providercode;
	}
	
	
	
	
	
	
}
